package com.esheeper.CAS.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    CheckOriginInterceptor checkOriginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //addPathPatterns拦截的路径
        String[] addPathPatterns = {
                "/**"
        };
        // 排除拦截路径
        //        excludePathPatterns排除的路径
        //        String[] excludePathPatterns = {
        //                "/user/login", "/user/noLg", "/user/error"
        //        };
        //创建用户拦截器对象并指定其拦截的路径和排除的路径
        registry.addInterceptor(checkOriginInterceptor).addPathPatterns(addPathPatterns);

        // 添加排除拦截路径
        //.excludePathPatterns(excludePathPatterns);
    }
}
